<?php

class PHPXControlTrait
{
	public function InitPHPX( )
	{
		$Loadable = new PHPXLoadableTrait( );
		$this->TraitOwner->Traits[] = $Loadable;
		$this->TraitOwner->InitTraits( );
		$Loadable->InitPHPX( );
	}
	
	public $PHPX = 'Default.phpx';
	
	public function GetPHPXPath( )
	{
		if( isset( $this->TraitOwner->Module ) )
		{
			return implode( '/', array( $this->TraitOwner->GetModulePath( ), $this->PHPX ) );	
		}
		else
		{
			return $this->PHPX;
		}
	}
	
	public function LoadPHPX( )
	{
		$XML = simplexml_load_file( $this->GetPHPXPath( ) );
		$this->Control = PHPX::GenerateComponent( $XML, $this );
	}
	
	public function Render( )
	{
		$this->Control->Render( );
	}
}